package com.monkey.springboot.demo.config;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.util.ResourceUtils;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @Title:
 * @Description:
 * @Author: zx
 * @Date: create in 10:36 2020/7/28
 * @Version: 1.0
 */
@Controller
@SpringBootApplication
@Configuration
public class CustomeWebConfiguration extends WebMvcConfigurationSupport {

    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**").addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX + "/templates/");
        registry.addResourceHandler("/**").addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX + "/static/");
    }

    /**
     * 配置多路由
     * @param registry
     */
    public void addViewControllers(ViewControllerRegistry registry) {

        registry.addViewController("today").setViewName("today");

        registry.addViewController("today1").setViewName("today1");

        registry.addViewController("today2").setViewName("today2");

        registry.addViewController("today3").setViewName("today3");

        registry.addViewController("today4").setViewName("today4");

        super.addViewControllers(registry);
    }

}
